home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Tools - Objects / MacApp / MacApp CD Release / MacApp 2.0.1 (Many Libraries) / Examples / DemoText / DemoText.r < prev    next >
Encoding:
Text File  |  1990-10-25  |  10.8 KB  |  427 lines  |  [TEXT/MPS ]

  1. /* Copyright © 1986-1990 by Apple Computer, Inc.  All rights reserved. */
  2.  
  3. /* • Auto-Include the requirements for this source */
  4. #ifndef __TYPES.R__
  5. #include "Types.r"
  6. #endif
  7.  
  8. #ifndef __MacAppTypes__
  9. #include "MacAppTypes.r"
  10. #endif
  11.  
  12. #if qTemplateViews
  13. #ifndef __ViewTypes__
  14. #include "ViewTypes.r"
  15. #endif
  16. #endif
  17.  
  18. #if qDebug
  19. include "Debug.rsrc";
  20. #endif
  21. include "MacApp.rsrc";
  22. include "Printing.rsrc";
  23.  
  24. include $$Shell("ObjApp")"DemoText" 'CODE';
  25.  
  26.  
  27. /* Resource ids */
  28.  
  29. #define kFileTooBig        1000                /* The 'File is too large' alert */
  30. #define kWindowRsrcID    1004
  31. #define kViewRsrcID        1005
  32.  
  33. #define kPromptsRsrcID    1005                /* STR# resource containing prompts */
  34.  
  35. #define mStyle               8                /* Hierarchical sub-menus */
  36. #define mSize               9
  37. #define mFont              10
  38. #define mColor              11
  39. #define hmStyle            "\0x08"                /* Byte values of hierarchical menu ids */
  40. #define hmSize            "\0x09"
  41. #define hmFont            "\0x0A"
  42. #define hmColor            "\0x0B"
  43.  
  44. #define kHierDisplayedMBar        131            /* MenuBar on hierarchical menu system */
  45.  
  46. /* Command numbers */
  47.  
  48. #define cWidthSuperView     601                /* View-width-determination commands */
  49. #define cWidthView         602
  50. #define cWidthOnePage     603
  51.  
  52. #define cHeightSuperView 604                /* View-height-determination commands */
  53. #define cHeightPages     605
  54. #define cHeightText         606
  55. #define cHeightConst     607
  56.  
  57. #define cJustForceLeft     608                /* Justification commands */
  58. #define cJustCenter         609
  59. #define cJustRight         610
  60. #define cJustSystem         611
  61.  
  62. #define cPlainText        1001                /* Typestyle attributes */
  63. #define cBold            1002
  64. #define cItalic         1003
  65. #define cUnderline        1004
  66. #define cOutline        1005
  67. #define cShadow         1006
  68. #define cCondense        1007
  69. #define cExtend         1008
  70.  
  71. #define cSizeChange     1100                /* Font-size commands */
  72. #define cSizeBase        1100
  73. #define cSizeMin        1109
  74. #define cSizeMax        1124
  75. #define cSizeGrow        1198
  76. #define cSizeShrink     1199
  77.  
  78. #define cJustChange     1200                /* Command numbers to cover other stylistic changes */
  79. #define cFontChange     1300
  80.  
  81. #define cStyle            1401                /* Command numbers for the hierarchial menu */
  82. #define cSize            1402
  83. #define cFont            1403
  84. #define cColor            1404
  85.  
  86. #define cColorChange    1500                /* Command numbers for changing colors */
  87. #define cColorText        1501
  88. #define cColorBackground 1502
  89.  
  90. #define kSignature        'SS04'                /* Application signature */
  91.  
  92. resource 'view' (kWindowRsrcID, purgeable) { {
  93.     root, 'WIND', { 50, 40 }, { 250, 450 }, sizeVariable, sizeVariable, shown, enabled,
  94.     Window {
  95.         "",
  96.             zoomDocProc, goAwayBox, resizable, modeless, ignoreFirstClick, freeOnClosing,
  97.             disposeOnFree, closesDocument, openWithDocument, dontAdaptToScreen, stagger,
  98.             forceOnScreen, dontCenter, 'TEVW', "" };
  99.  
  100.     'WIND', 'SCLR',    { 0, 0 }, { 250-kSBarSizeMinus1, 450-kSBarSizeMinus1 },
  101.     sizeRelSuperView, sizeRelSuperView, shown, enabled,
  102.     Scroller {
  103.         "",
  104.             vertScrollBar, horzScrollBar, 0, 0, 16, 16,
  105.             vertConstrain, horzConstrain, { 0, 0, 0, 0 } };
  106.     
  107.     'SCLR', IncludeViews { kViewRsrcID }
  108. } };
  109.  
  110.  
  111. resource 'view' (kViewRsrcID, purgeable) {{
  112.     root, 'TEVW', { 0, 0 }, { 116, 1020 }, sizeVariable, sizePage, shown, enabled,
  113.     TEView {
  114.         "",
  115.             withStyle, autoWrap, acceptChanges, dontFreeText, cTyping, unlimited,
  116.             { 8, 10, 0, 10 }, justSystem, applFont12 }
  117. } };
  118.  
  119.  
  120. resource 'STR#' (kPromptsRsrcID, purgeable) {
  121.     {
  122. /* [ 1] */    "Select a new text color…",
  123. /* [ 2] */    "Select background color…"
  124.     }
  125. };
  126.  
  127. resource 'SIZE' (-1) {
  128.     saveScreen,
  129.     acceptSuspendResumeEvents,
  130.     enableOptionSwitch,
  131.     canBackground,
  132.     MultiFinderAware,
  133.     backgroundAndForeground,
  134.     dontGetFrontClicks,
  135.     ignoreChildDiedEvents,
  136.     is32BitCompatible,
  137.     reserved,
  138.     reserved,
  139.     reserved,
  140.     reserved,
  141.     reserved,
  142.     reserved,
  143.     reserved,
  144. #if qdebug
  145.     450 * 1024,
  146.     368 * 1024
  147. #else
  148.     300 * 1024,
  149.     200 * 1024
  150. #endif
  151. };
  152.  
  153. /*    Printing to the LaserWriter is the time when the most temporary memory
  154.     is in use.  We need the segments in use at that time */
  155.  
  156. resource 'seg!' (256, purgeable) {
  157.     {
  158.         "GWriteFile";
  159.         "GClipboard";
  160.         "GNonRes";
  161.         "GFile";
  162.         "GSelCommand";
  163.         "GTerminate";
  164.         "GClose";
  165.         "GDoCommand";
  166.     }
  167. };
  168.  
  169. resource 'DITL' (phAboutApp, purgeable) {
  170.      {
  171. /* [ 1] */    {160, 182, 180, 262},
  172.             Button {
  173.                 enabled,
  174.                 "OK"
  175.             };
  176. /* [ 2] */    {10, 75, 150, 320},
  177.             StaticText {
  178.                 disabled,
  179.                     "This sample program demonstrates how to use various features of "
  180.                     "the “TEView” building block of MacApp.\n\nThis program was written "
  181.                     "with MacApp® © 1985-1990 Apple Computer, Inc."
  182.             };
  183. /* [ 3] */    {10, 20, 42, 52},
  184.             Icon {
  185.                 disabled,
  186.                 1
  187.             }
  188.     }
  189. };
  190.  
  191. include "Defaults.rsrc"  'ALRT' (phAboutApp);    // Grab the default about box
  192.  
  193. /* Used when the user attempts to read a file larger than we can handle */
  194.  
  195. resource 'DITL' (kFileTooBig, purgeable) {
  196.     {
  197. /* [ 1] */    {82, 198, 100, 272},
  198.                 Button {
  199.                     enabled,
  200.                     "OK"
  201.                 };
  202. /* [ 2] */    {10, 70, 77, 272},
  203.                 StaticText {
  204.                     disabled,
  205.                     "DemoText can’t read the entire file because it is too long."
  206.                 };
  207. /* [ 3] */    {10, 20, 42, 52},
  208.                 Icon {
  209.                     disabled,
  210.                     0
  211.                 }
  212.     }
  213. };
  214.  
  215. resource 'ALRT' (kFileTooBig, purgeable) {
  216.     {100, 110, 210, 402},
  217.     kFileTooBig,
  218.     {
  219. /* [ 1] */    OK, visible, silent;
  220. /* [ 2] */    OK, visible, silent;
  221. /* [ 3] */    OK, visible, silent;
  222. /* [ 4] */    OK, visible, silent
  223.     }
  224. };
  225.  
  226. include "Defaults.rsrc" 'cmnu' (mApple);        // Grab the default Apple/File menus
  227. include "Defaults.rsrc" 'cmnu' (mFile);
  228.  
  229. resource 'cmnu' (mEdit) {
  230.     mEdit,
  231.     textMenuProc,
  232.     AllEnabled,
  233.     enabled,
  234.     "Edit",
  235.      {
  236. /* [ 1] */    "Undo",                noIcon,    "Z",    noMark,    plain,    cUndo;
  237. /* [ 2] */    "-",                noIcon,    noKey,    noMark,    plain,    nocommand;
  238. /* [ 3] */    "Cut",                noIcon,    "X",    noMark,    plain,    cCut;
  239. /* [ 4] */    "Copy",                noIcon,    "C",    noMark,    plain,    cCopy;
  240. /* [ 5] */    "Paste",            noIcon,    "V",    noMark,    plain,    cPaste;
  241. /* [ 6] */    "Clear",            noIcon,    noKey,    noMark,    plain,    cClear;
  242. /* [ 7] */    "-",                noIcon,    noKey,    noMark,    plain,    nocommand;
  243. /* [ 8] */    "Select All",        noIcon,    "A",    noMark,    plain,    cSelectAll;
  244. /* [ 9] */    "-",                noIcon,    noKey,    noMark,    plain,    nocommand;
  245. /* [10] */    "Show Clipboard",    noIcon,    noKey,    noMark,    plain,    cShowClipboard;
  246. /* [11] */    "-",                noIcon,    noKey,    noMark,    plain,    nocommand;
  247. /* [12] */    "Show Page Breaks",    noIcon, noKey,    noMark,    plain,    cShowBreaks
  248.     }
  249. };
  250.  
  251. resource 'cmnu' (5) {
  252.     5,
  253.     textMenuProc,
  254.     AllEnabled,
  255.     enabled,
  256.     "Text",
  257.      {
  258. /* [ 1] */    "View as wide as SuperView",
  259.                                 noIcon,    noKey,    noMark,    plain,    cWidthSuperView;
  260. /* [ 2] */    "View width frozen",
  261.                                 noIcon,    noKey,    noMark,    plain,    cWidthView;
  262. /* [ 3] */    "View as wide as one page",
  263.                                 noIcon,    noKey,    noMark,    plain,    cWidthOnePage;
  264. /* [ 4] */    "-",                noIcon,    noKey,    noMark,    plain,    nocommand;
  265. /* [ 5] */    "View as high as the SuperView",
  266.                                 noIcon,    noKey,    noMark,    plain,    cHeightSuperView;
  267. /* [ 6] */    "View height an exact number of pages",
  268.                                 noIcon,    noKey,    noMark,    plain,    cHeightPages;
  269. /* [ 7] */    "View as high as its content",
  270.                                 noIcon,    noKey,    noMark,    plain,    cHeightText;
  271. /* [ 8] */    "View height frozen",
  272.                                 noIcon,    noKey,    noMark,    plain,    cHeightConst;
  273. /* [ 9] */    "-",                noIcon,    noKey,    noMark,    plain,    nocommand;
  274. /* [10] */    "System justified",    noIcon,    noKey,    noMark,    plain,    cJustSystem;
  275. /* [11] */    "Force Left justified",    noIcon,    noKey,    noMark,    plain,    cJustForceLeft;
  276. /* [12] */    "Center justified",    noIcon,    noKey,    noMark,    plain,    cJustCenter;
  277. /* [13] */    "Right justified",    noIcon,    noKey,    noMark,    plain,    cJustRight
  278.     }
  279. };
  280.  
  281. /* Hierarchical  Format menu with Style, Size and Font submenus */
  282. resource 'cmnu' (7) {
  283.     7,
  284.     textMenuProc,
  285.     allEnabled,
  286.     enabled,
  287.     "Format",
  288.      {
  289. /* [ 1] */    "Style",            noIcon, kHierarchicalMenu, hmStyle, plain, cStyle;
  290. /* [ 2] */    "Size",                noIcon, kHierarchicalMenu, hmSize, plain, cSize;
  291. /* [ 3] */    "Font",                noIcon, kHierarchicalMenu, hmFont, plain, cFont;
  292. /* [ 4] */    "Color",            noIcon, kHierarchicalMenu, hmColor, plain, cColor
  293.     }
  294. };
  295.  
  296. /* Hierarchical Style Sub-menu */
  297. resource 'cmnu' (mStyle) {
  298.     mStyle,
  299.     textMenuProc,
  300.     allEnabled,
  301.     enabled,
  302.     "Style",
  303.      {
  304. /* [ 1] */    "Plain Text",        noIcon,    noKey,    noMark,    plain,        cPlainText;
  305. /* [ 2] */    "Bold",                noIcon,    noKey,    noMark,    bold,        cBold;
  306. /* [ 3] */    "Italic",            noIcon,    noKey,    noMark,    italic,        cItalic;
  307. /* [ 4] */    "Underline",        noIcon,    noKey,    noMark,    underline,    cUnderline;
  308. /* [ 5] */    "Outline",            noIcon,    noKey,    noMark,    outline,    cOutline;
  309. /* [ 6] */    "Shadow",            noIcon,    noKey,    noMark,    shadow,        cShadow;
  310. /* [ 7] */    "Condensed",        noIcon,    noKey,    noMark, condense,    cCondense;
  311. /* [ 8] */    "Extended",            noIcon,    noKey,    noMark, extend,        cExtend
  312.     }
  313. };
  314.  
  315. /* Hierarchical Size Sub-menu */
  316. resource 'cmnu' (mSize) {
  317.     mSize,
  318.     textMenuProc,
  319.     AllEnabled,
  320.     enabled,
  321.     "Size",
  322.      {
  323. /* [ 1] */    " 9 Point",            noIcon,    noKey,    noMark,    plain,    cSizeBase+9;
  324. /* [ 2] */    "10 Point",            noIcon,    noKey,    noMark,    plain,    cSizeBase+10;
  325. /* [ 3] */    "12 Point",            noIcon,    noKey,    noMark,    plain,    cSizeBase+12;
  326. /* [ 4] */    "14 Point",            noIcon,    noKey,    noMark,    plain,    cSizeBase+14;
  327. /* [ 5] */    "18 Point",            noIcon,    noKey,    noMark,    plain,    cSizeBase+18;
  328. /* [ 6] */    "24 Point",            noIcon,    noKey,    noMark,    plain,    cSizeBase+24;
  329. /* [ 7] */    "-",                noIcon,    noKey,    noMark,    plain,    nocommand;
  330. /* [ 8] */    "Grow selection",    noIcon,    "]",    noMark,    plain,    cSizeGrow;
  331. /* [ 9] */    "Shrink selection",    noIcon,    "[",    noMark,    plain,    cSizeShrink
  332.  
  333.      }
  334. };
  335.  
  336. /* Font menu for hierarchical or non-hierarchical system */
  337. resource 'MENU' (mFont) {
  338.     mFont,
  339.     textMenuProc,
  340.     allEnabled,
  341.     enabled,
  342.     "Font",
  343.     { }
  344. };
  345.  
  346. resource 'cmnu' (mColor) {
  347.     mColor,
  348.     textMenuProc,
  349.     allEnabled,
  350.     enabled,
  351.     "Color",
  352.     {
  353. /* [ 1] */    "Set text color…",    noIcon,    "T",    noMark,    plain,    cColorText;
  354. /* [ 2] */    "Set background color…",
  355.                                 noIcon,    "K",    noMark,    plain,    cColorBackground
  356.     }
  357. };
  358.  
  359. resource 'cmnu' (mBuzzwords) {
  360.     mBuzzwords,
  361.     textMenuProc,
  362.     allEnabled,
  363.     enabled,
  364.     "Buzzwords",
  365.     {
  366.         "Typing",                noIcon,    noKey,    noMark,    plain,    cTyping;
  367.         "Style Change",            noIcon,    noKey,    noMark,    plain,    cStyleChange;
  368.         "Size Change",            noIcon,    noKey,    noMark,    plain,    cSizeChange;
  369.         "Justification Change",    noIcon,    noKey,    noMark,    plain,    cJustChange;
  370.         "Font Change",            noIcon,    noKey,    noMark,    plain,    cFontChange;
  371.         "Color Change",            noIcon,    noKey,    noMark,    plain,    cColorChange;
  372.         "Page Setup Change",    noIcon,    noKey,    noMark,    plain,    cChangePrinterStyle
  373.     }
  374. };
  375.  
  376. /* Displayed menus on a non-hierarchical system */
  377. resource 'MBAR' (kMBarDisplayed) {
  378.     {mApple; mFile; mEdit; 5; 8; 9; 10; 11}
  379. };
  380.  
  381. /* Displayed menus on a hierarchical system */
  382. resource 'MBAR' (kHierDisplayedMBar) {
  383.     {mApple; mFile; mEdit; 5; 7}
  384. };
  385.  
  386. /* Hierarchial Sub-Menus */
  387. resource 'MBAR' (kMBarHierarchical) {
  388.     {8; 9; 10; 11}
  389. };
  390.  
  391. include "Defaults.rsrc"  'STR#' (kDefaultCredits);        // Grab the default credits
  392. resource 'BNDL' (128,
  393. #if qNames
  394. "DemoText",
  395. #endif
  396.     purgeable) {
  397.     kSignature,
  398.     0,
  399.     {
  400.         'ICN#',
  401.         {
  402.             0, 128,
  403.         },
  404.         'FREF',
  405.         {
  406.             0, 128,
  407.         }
  408.     }
  409. };
  410.  
  411. type kSignature as 'STR ';
  412. resource kSignature (0,
  413. #if qNames
  414. "Signature",
  415. #endif
  416.     purgeable) {
  417.     "DemoText 2.0 ©Apple Computer, Inc. 1988-1990"
  418. };
  419.  
  420. // Get the default MacApp® application icon and file reference
  421. include "Defaults.rsrc"  'ICN#' (128);
  422. include "Defaults.rsrc"  'FREF' (128);
  423.  
  424. // Get the default Version resources
  425. include "Defaults.rsrc"  'vers' (1);        // Application or file specific
  426. include "Defaults.rsrc"  'vers' (2);        // Overall package
  427.